<?php
//Khai báo thư mục chính
define('ROOT_URL', 'http://localhost/fs-SlideShow/');
//Khai báo thư mục chứa ảnh
define('FOL_IMG', 'img_Slide');
//Khai báo id slideshow
define('ID_SLIDE', 'SlideShow');
/*
  @Name project:
  @Coding : Nguyễn Trần Minh Trung
  @Date: 01/08/2014
 */
?>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="<?php echo ROOT_URL ?>fs_SlideShow/css/S_Reset.css">
        <link type="text/css" rel="stylesheet" href="<?php echo ROOT_URL ?>fs_SlideShow/css/S_Style.css">
        <script type="text/javascript" src="<?php echo ROOT_URL ?>fs_SlideShow/js/jquery-v1.8.3.js"></script>
        <script type="text/javascript" src="<?php echo ROOT_URL ?>fs_SlideShow/js/fs_SlideShow.js"></script>
        <script type="text/javascript">
            lnk = '<?php echo ROOT_URL ?>';
            $(document).ready(function() {
                $('#<?php echo ID_SLIDE ?>').fs_SlideShow({
                    width:500,
                    height:300,
                    style:{
                        type:'stack',
                        num_Img:5
                    },
                    affect: {
                        type:'slideHor',
                        time:800,
                    },
//                    autoUpDown:true,
                    timeInterval:1000,
//                    autoSlide:true
                });
            });
        </script>
    </head>
    <body>
        <div id="<?php echo ID_SLIDE ?>" class="fs_SlideShow">
            <div class="SlideShow">
                <?php
                //Chiều dài ảnh
                $wid = 300;
                //Chiều rộng ảnh nếu có
                $hei = 200;
                //Khai báo mảng chứa những file hình ảnh
                $files = array();
                //Khai báo folder chứa ảnh
                $dir = opendir(FOL_IMG);
                while ($f = readdir($dir)) {
                    //Danh sách đuôi cho phép
                    if (preg_match("/(.*).jpg$/", $f)) {
                        $files[] = $f;
                    }
                }
                closedir($dir);
                $data = array();
                if (!empty($files)) {
                    foreach ($files as $v) {
                        ?>
                        <a href="#">
                            <img alt="<?php echo $v ?>" <?php if (isset($hei)) echo 'height="' . $hei . 'px"' ?> width="<?php echo $wid ?>px" src="<?php echo ROOT_URL . FOL_IMG . '/' . $v; ?>" />
                        </a>
                        <?php
                    }
                }
                ?>
            </div>
        </div>
    </body>
</html>
